package cn.jsprun.utils;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public final class Config {
	private Properties properties=null;
	private String fileName=null;
	public Config(String fileName)
	{
		this.properties = new Properties();
		this.fileName=fileName;
		try {
			InputStream fis = new FileInputStream(fileName);
			this.properties.load(fis);
			fis.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public Properties getProperties()
	{
		return properties;
	}
	public void setProperties(Properties properties) {
		this.properties = properties;
	}
	public String getValue(String key) {
		return properties.getProperty(key);
	}
	public void setValue(String key,String value) {
		properties.setProperty(key, value);
	}
	public void saveProperties(String comments)
	{
		FileOutputStream out;
		try {
			out = new FileOutputStream(fileName);
			properties.store(out, comments);
			out.flush(); 
			out.close(); 
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
